A plurality of layers are stacked in a semiconductor device. It is required to detect an alignment error of patterns between the plurality of layers with high accuracy.